const Ws = require('ws');
; ((Ws) => {
    const serve = new Ws.Server({ port: 8000 })
    const init = () => {
        bindEvent()
    }
    function bindEvent() {
        serve.on('open', handleOpen)
        serve.on('close', handleClose)
        serve.on('error', handleError)
        serve.on('connection', handleConnection)
    }
    function handleOpen() {
        console.log('open');
    }
    function handleClose() {
        console.log('close');
    }
    function handleError() {
        console.log('erroe');
    }
    function handleConnection(ws) {
        ws.on('message', handleMessage)
    }
    function handleMessage(msg) {
        serve.clients.forEach(function (c) {
            c.send(msg.toString())
        })
    }
    init()
})(Ws);